// 导入封装好的axios
import request from './request'
import qs from "qs"

// 定义一个请求精品的数据
export const JingPinAPI = () => request.get('/products/recommend')

// 请求热门兑换的数据
export const HotAPI = () => request.get("/products/hot");

// 定义一个发送验证码的请求
// params 预期  {phone:13537315042}
// 【第一步: 定义方法，请求接口】
export const SendSMSAPI = (params) => request.post("/sendSMS", qs.stringify(params))

// 登录请求
export const PhoneReginAPI = (params) => request.post("/phoneRegin", qs.stringify(params))

// 微信登录（这个接口必须用qs对数据进行格式化）
export const WeixinLoginAPI = (params) => request.post(`/wechatUsers/PCLogin`, qs.stringify(params));

// 手机号绑定
export const BindingAPI = (params) => request.post(`/wechatUsers/binding`, qs.stringify(params));

// 获取登录用户信息
export const UserProfilesAPI = () => request.get("/shop/userProfiles");

// 商品详情
export const DetailsAPI = (id) => request.get(`/products/${id}`);

// 加入购物车
export const AddToCartPI = (params) => request.post(`/shop/carts/add`, qs.stringify(params));

// 全部商品搜索
export const GoodsSearchAPI = (params) => request.get(`/products`, { params });  //params:params  get传参

// 请求购物车
export const CartsAPI = () => request.get(`/shop/carts`);

// 删除购物车商品 
export const DeleteAPI = (id) => request.delete(`/shop/carts?productIds=${id}`);